
import java.util.Scanner;


public class code049 {
	public static void main(String[] args) {
		String name = " ";//商品名称
		double price = 0.0;//商品价格
		int goodsNo = 0;//商品编号
		int amount = 0;//购买数量
		double sum = 0.0;//小计
		double discount = 0.8;//折扣比例
		double total = 0.0;//商品总价
		double payment = 0.0;//实付金额
		double change = 0.0;//找零
		System.out.println("MyShopping管理系统>购物结算\n");
		//商品清单
		System.out.println("*************************");
		System.out.println("请选择购买物品编号：");
		System.out.println("1.T恤    2.网球鞋   3.网球拍");
		System.out.println("*************************");
		Scanner input = new Scanner(System.in);
		String answer = "y";//标识是否继续
		while("y".equals(answer)){
			System.out.println("请输入商品编号");
			goodsNo = input.nextInt();
			switch (goodsNo){
			case 1:
				name = "T恤";
				price = 245.0;
				break;
			case 2:
				name = "网球鞋";
				price = 570.0;
				break;
			case 3:
				name = "网球拍";
				price = 320.0;
				break;
				default:
					System.out.println("您输入的商品编号有误。请重新输入：");
					goodsNo = input.nextInt();
					break;
			}
			System.out.print("请输入购买数量：");
			amount = input.nextInt();
			sum = price * amount;
			System.out.println(name+ "\t"+"¥"+price+"\n");
			System.out.println("是否继续(y/n)");
			answer = input.next();
			total = total + sum;
		}
		System.out.println("折扣：0.8");
		total = total * discount;
		System.out.println("应付金额：" + total);
		System.out.println("实付金额：");
		payment = input.nextDouble();
		change = payment - total;
		System.out.println("找零：" + change);
	}
}

